package com.epfresh.supplier.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.epfresh.supplier.R;
import com.epfresh.supplier.entity.CancelDebtRecordEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by shenjie on 2017/9/22.
 */

public class CancelDebtRecordAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<CancelDebtRecordEntity.CancelDebtList> list;

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public List<CancelDebtRecordEntity.CancelDebtList> getList() {
        return list;
    }

    public void setList(ArrayList<CancelDebtRecordEntity.CancelDebtList> list) {
        this.list = list;
    }

    public CancelDebtRecordAdapter(Context context, ArrayList<CancelDebtRecordEntity.CancelDebtList> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView==null){
            holder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.list_canceldebt,null);
            holder.custome= (TextView) convertView.findViewById(R.id.customerinfo);
            holder.date= (TextView) convertView.findViewById(R.id.time);
            holder.wait= (TextView) convertView.findViewById(R.id.wait);
            convertView.setTag(holder);
        }
        holder= (ViewHolder) convertView.getTag();
        CancelDebtRecordEntity.CancelDebtList entity=list.get(position);
        holder.custome.setText(entity.getCustomerName()+" "+entity.getBuyerNumber());
        if(entity.getCreateTime()!=null){
            holder.date.setText(entity.getCreateTime().split(" ")[0]);
        }
        holder.wait.setText("收款:"+entity.getPayFee()+"元");
        return convertView;
    }

    class  ViewHolder{
        TextView custome,date,wait;
    }
}
